package com.tz.fruit.service.impl;

import com.tz.fruit.dao.ICartDao;
import com.tz.fruit.entity.*;
import com.tz.fruit.service.ICartService;
import com.tz.fruit.service.IShoppingCart;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * Created by Tyranty on 2017/7/20 0020.
 */
@Service
public class CartServiceImpl implements ICartService {

    @Autowired
    private ICartDao cartDao;


    @Override
    public void saveProduct(Product product) {
        cartDao.saveProduct(product);
    }

    @Override
    public Product findProductByPid(Long pid) {
        return cartDao.findProductByPid(pid);
    }

    @Override
    public void saveUser(User user) {
        cartDao.saveUser(user);
    }

    @Override
    public User findUserByUserId(Long userId) {
        return cartDao.findUserByUserId(userId);
    }

    @Override
    public void saveCart(Cart cart) {
        cartDao.saveCart(cart);
    }

    @Override
    public void updateCart(Cart cart) {
        cartDao.updateCart(cart);
    }

    @Override
    public Cart findCartByUserId(Long userId) {
        return cartDao.findCartByUserId(userId);
    }

    @Override
    public void saveOrder(Order order) {
        cartDao.saveOrder(order);
    }

    @Override
    public Order findOrderByOrderNo(String orderNo) {
        return cartDao.findOrderByOrderNo(orderNo);
    }

    @Override
    public void saveOrderItem(OrderItem orderItem) {
        cartDao.saveOrderItem(orderItem);
    }

    @Override
    public OrderItem findOrderItemByPNo(String pNo) {
        return cartDao.findOrderItemByPNo(pNo);
    }

    @Override
    public OrderItem findOrderItemByItemId(Long itemId) {
        return cartDao.findOrderItemByItemId(itemId);
    }

    @Override
    public void updateOrderItem(OrderItem orderItem) {
        cartDao.updateOrderItem(orderItem);
    }

    @Override
    public void deleteByOrderItemId(Long itemId) {
        cartDao.deleteByOrderItemId(itemId);
    }

    @Override
    public List<OrderItem> findAll(Long cartId) {
        return cartDao.findAll(cartId);
    }
}
